package com.virtualperson.config;

import com.virtualperson.service.ObjectStorageService;
import com.virtualperson.service.impl.AliyunOssStorageServiceImpl;
import com.virtualperson.service.impl.AliyunServerStorageServiceImpl;
import com.virtualperson.service.impl.LocalStorageServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class StorageConfig {

    @Value("${app.storage.type:local}")
    private String storageType;

    @Bean
    @Primary
    public ObjectStorageService objectStorageService() {
        switch (storageType.toLowerCase()) {
            case "oss":
                return new AliyunOssStorageServiceImpl();
            case "server":
                return new AliyunServerStorageServiceImpl();
            case "local":
            default:
                return new LocalStorageServiceImpl();
        }
    }
} 